home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_SimpleQuery_JScript.asp < prev    next >
Encoding:
Text File  |  1999-07-21  |  1.2 KB  |  71 lines

  1. <%@ LANGUAGE = JScript %>
  2.  
  3. <HTML>
  4.     <HEAD>
  5.         <TITLE>Simple ADO Query</TITLE>
  6.     </HEAD>
  7.  
  8.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  9.  
  10.  
  11.         <!-- Display Header -->
  12.  
  13.         <font size="4" face="Arial, Helvetica">
  14.         <b>Simple ADO Query with ASP</b></font><br>
  15.     
  16.         <hr size="1" color="#000000">
  17.  
  18.         Contacts within the Authors Database:<br><br>
  19.  
  20.         <%
  21.             var oConn;        
  22.             var oRs;        
  23.             var filePath;        
  24.  
  25.             
  26.             // Map authors database to physical path
  27.             
  28.             filePath = Server.MapPath("authors.mdb");
  29.  
  30.  
  31.             // Create ADO Connection Component to connect with
  32.             // sample database
  33.            
  34.  
  35.             
  36.             oConn = Server.CreateObject("ADODB.Connection");
  37.             oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +filePath);
  38.             
  39.             
  40.             // Execute a SQL query and store the results within
  41.             // recordset
  42.             
  43.             oRs = oConn.Execute("SELECT * From authors");
  44.         %>
  45.  
  46.  
  47.         <TABLE border = 1>
  48.         <%  
  49.             while (!oRs.eof) { %>
  50.  
  51.                 <tr>
  52.                     <% for(Index=0; Index < (oRs.fields.count); Index++) { %>
  53.                         <TD VAlign=top><% = oRs(Index)%></TD>
  54.                     <% } %>
  55.                 </tr>
  56.             
  57.                 <% oRs.MoveNext();
  58.             } 
  59.         %>
  60.  
  61.         </TABLE>
  62.  
  63.  
  64.         <%   
  65.             oRs.close();
  66.             oConn.close();
  67.         %>
  68.  
  69.     </BODY>
  70. </HTML>
  71.